<?php $i = 0;
$j = 0;
foreach ($categories as $key => $value): ?>

    <?php if ($value['depth'] == 1): ?>
        <?php
        $i++;
        $class = 'women';
        if ($i % 2 == 0) {
            $class = 'men';
        }
        ?>
        <div class="<?php echo $class; ?>">
            <div class="title">
                <a href="<?php echo Configure::read('base_url'); ?>products/browsebycategory/<?php echo $value['id']; ?>" class="lnk" >
                <?php echo $value['category_name'] . "(" . $value['total_product'] . ")"; ?></a></div>
            <div class="bodywrapper" style="text-transform: uppercase;">
            <?php endif; ?>
            <?php
            if ($value['depth'] != 1):
                $margin = $value['depth'] * 2 * 10;
                $arrow = '&gt;&nbsp;';
                if ($value['depth'] == 2) {
                    $margin = 0;
                    $margintop = 35;
                    $arrow = '&gt;&gt;&nbsp;';
                } else {
                    $margintop = 5;
                }
                ?>
                <p style="margin-left:<?php echo $margin; ?>px;margin-top:<?php echo $margintop; ?>px;"><?php echo $arrow . ' '; ?>
                   <a href="<?php echo Configure::read('base_url'); ?>products/browsebycategory/<?php echo $value['id']; ?>">
                        <?php echo $value['category_name'] . "(" . $value['total_product'] . ")"; ?></a>
                </p>
            <?php endif; ?>
            <?php if ($key == count($categories)): ?>
                <div class="clear"></div>
            </div>
        </div>
        <?php break;
    endif; ?>
    <?php if ($categories[$key + 1]['depth'] == 1): ?>
        <div class="clear"></div>
        </div>
        </div>
    <?php endif; ?>
    <?php //endif;?>
<?php endforeach; ?>